package com.cfg.waf;

import com.cfg.waf.Constants.KafkaConstants;
import com.cfg.waf.kafka.Consumer;
import com.cfg.waf.kafka.Producer;
import org.apache.kafka.clients.consumer.ConsumerConfig;
import org.apache.kafka.clients.producer.ProducerConfig;
import org.apache.kafka.common.serialization.StringDeserializer;
import org.apache.kafka.common.serialization.StringSerializer;
import java.util.Properties;


/**
 * Hello world!
 *
 */
public class App {
    public static void main( String[] args ) {

        Properties properties1 = new Properties();
        properties1.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, KafkaConstants.BOOTSTRAP_SERVERS_CONFIG);
        properties1.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class);
        properties1.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, StringSerializer.class);

        Producer producer = new Producer(properties1, KafkaConstants.topic);
        producer.start();

        Properties properties2 = new Properties();
        properties2.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, KafkaConstants.BOOTSTRAP_SERVERS_CONFIG);
        properties2.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class);
        properties2.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class);
        properties2.put(ConsumerConfig.GROUP_ID_CONFIG, KafkaConstants.topic);

        Consumer consumer = new Consumer(properties2, KafkaConstants.topic);
        consumer.start();

    }
}
